<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<form id="pagerForm" method="get" model="viewRequest" action="${rootUrl}/order/storage-order/${storageOrder.id}/edit">
</form>
<div class="pageContent">
	<form method="post" id="mainFormId" action="" class="pageForm required-validate" onsubmit="return validateCallback(this, newDialogAjaxDone);">
		<c:if test="${storageOrder.id != 0 && storageOrder.id != '' }"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" name="storageOrder.id" value="${storageOrder.id }">
		<div class="pageFormContent" layoutH="56">
			<fieldset>
				<legend>订单详情</legend>
				<p>
					<label>订单编号：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" size="30" value="${storageOrder.order.code }" />
				</p>
				<p>
					<label>买家：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" value="${storageOrder.member.loginname}" />
					<a class="buttonActive" href="${rootUrl}/member/member!detail?id=${storageOrder.member.id}" title="会员详情" buttonActiverel="member_detail_orders" rel="member_detail" target="dialog" width="800" height="600"><span>会员详情</span></a>
				</p>
				<p>
					<label>支付时间：</label>
					<input name="storageOrder.order.inventory" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.order.payTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" />
				</p>
				<p>
					<label>商品金额：</label>
					<input name="storageOrder.order.subTitle" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.goodsAmount/100}" pattern="0.00"/>" />
				</p>
				<p>
					<label>优惠金额：</label>
					<input name="storageOrder.order.inventory" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.discountAmount/100}" pattern="0.00"/>" />
				</p>
				<p>
					<label>订单金额：</label>
					<input name="storageOrder.order.subTitle" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.orderAmount/100}" pattern="0.00"/>" />
				</p>
				<p>
					<label>运费金额：</label>
					<input name="storageOrder.order.inventory" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.freightAmount/100}" pattern="0.00"/>" />
				</p>
				<p>
					<label>应付金额：</label>
					<input name="storageOrder.order.subTitle" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.resultAmount/100}" pattern="0.00"/>" />
				</p>
				<p>
					<label>退款金额：</label>
					<input name="storageOrder.order.inventory" class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.order.refundAmount/100}" pattern="0.00"/>" />
				</p>
				<%-- <p>
					<label>订单状态：</label>
					<input name="storageOrder.order.inventory" readonly="readonly" type="text" size="30" value="${orderState[storageOrder.order.state]}" />
				</p> --%>
				<p>
					<label>取消时间：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.order.cancelTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" />
				</p>
				<p>
					<label>退款时间：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.order.refundTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" />
				</p>
				<p>
					<label>完成时间：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.order.finishTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" />
				</p>
				<p>
					<label>收货人：</label>
					<input name="storageOrder.order.subTitle" readonly="readonly" type="text" size="30" value="${storageOrder.order.name}" />
				</p>
				<p style="width: 700px">
					<label>收货地址：</label>
					<input name="storageOrder.order.inventory" readonly="readonly" type="text" size="80" value="${storageOrder.order.address }" />
				</p>
			</fieldset>
			<div class="tabs" currentIndex="0" eventType="click">
				<div class="tabsHeader">
					<div class="tabsHeaderContent">
						<ul>
							<li><a href="javascript:;"><span>${storageOrder.storage.name}</span></a></li>
						</ul>
					</div>
				</div>
				<div class="tabsContent">
					<div>
						<fieldset>
							<legend>二级订单详情</legend>
							<p>
								<label>二级订单编号：</label>
								<input name="orders.subTitle" readonly="readonly" type="text" size="30" value="${storageOrder.code }" />
							</p>
							<p>
								<label>商家：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="${storageOrder.seller.name }" />
							</p>
							<p>
								<label>快递名称：</label>
								<input name="storageOrder.express.id" type="hidden" size="30" value="${storageOrder.express.id}" />
								<input name="storageOrder.express.name" <c:if test="${storageOrder.state != 21}">class="required"</c:if> readonly="readonly" type="text" size="30" value="${storageOrder.express.name }" />
								<a class="btnLook" href="${rootUrl}/seller/express/0/dialog?sellerId=${storageOrder.seller.id }" lookupGroup="storageOrder.express">快递选择</a>
							</p>
							<p>
								<label>快递单号：</label>
								<c:if test="${storage.storage.storageType.code != 'zzfreetax' }">
									<input name="storageOrder.expressCode" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> <c:if test="${storageOrder.state != 21}">class="required"</c:if> type="text" size="30" value="${storageOrder.expressCode }" />
								</c:if>
								<c:if test="${storage.storage.storageType.code == 'zzfreetax' }">
									<input readonly="readonly" type="text" size="30" value="<c:if test="${storageOrder.expressCode == ''}">海关订单，不需填写订单号</c:if><c:if test="${storageOrder.expressCode != ''}">${storageOrder.expressCode }</c:if>" />
								</c:if>
							</p>
							<p>
								<label>重量(克)：</label>
								<input name="storageOrder.weight" readonly="readonly" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> <c:if test="${storageOrder.state != 21}">class="required"</c:if> type="text" size="30" value="${storageOrder.weight }" />
							</p>
							<p>
								<label>运费：</label>
								<input name="freight" readonly="readonly" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> <c:if test="${storageOrder.state != 21}">class="required"</c:if> type="text" size="30" value="<fmt:formatNumber value="${storageOrder.freight/100}" pattern="0.00"/>" />
							</p>
							<p>
								<label>超重运费：</label>
								<input name="overFreight" readonly="readonly" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> type="text" size="30" value="<fmt:formatNumber value="${storageOrder.overweightFreight/100}" pattern="0.00"/>" />
							</p>
							<p>
								<label>发货时间：</label>
								<input name="storageOrder.deliveryTime" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> class=" <c:if test="${storageOrder.state != 21}">required</c:if> date" type="text" dateFmt="yyyy-MM-dd HH:mm:ss" size="30" value="<fmt:formatDate value='${storageOrder.deliveryTime }' pattern="yyyy-MM-dd HH:mm:ss"/>" />
								<a class="inputDateButton" href="javascript:;">选择</a>
							</p>
							<p>
								<label>确认收货时间：</label>
								<input name="storageOrder.receiptTime" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.receiptTime }' pattern="yyyy-MM-dd HH:mm:ss"/>" />
							</p>
							<p>
								<label>截至收货时间：</label>
								<input name="storageOrder.receiptEndTime" <c:if test="${storageOrder.state != 30}"> readonly="readonly"</c:if> class="date  <c:if test="${storageOrder.state != 21}">required</c:if>" dateFmt="yyyy-MM-dd HH:mm:ss" type="text" size="30" value="<fmt:formatDate value='${storageOrder.receiptEndTime }' pattern="yyyy-MM-dd HH:mm:ss"/>" />
								<a class="inputDateButton" href="javascript:;">选择</a>
							</p>
							<p>
								<label>退款时间：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="<fmt:formatDate value='${storageOrder.refundTime }' pattern="yyyy-MM-dd HH:mm:ss"/>" />
							</p>
							<p>
								<label>商品总价格：</label>
								<input name="orders.subTitle" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.goodsAmount/100}" pattern="0.00"/>" />
							</p>
							<p>
								<label>优惠金额：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.discountAmount/100}" pattern="0.00"/>" />
							</p>
							<p>
								<label>应付价格：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.resultAmount/100}" pattern="0.00"/>" />
							</p>
							<p>
								<label>退款金额：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value="${storageOrder.refundAmount/100}" pattern="0.00"/>" />
							</p>
							<%-- <p>
								<label>订单状态：</label>
								<input name="storageOrder.state" id="orderState" readonly="readonly" type="hidden" value="${storageOrder.state }" />
								<input name="" readonly="readonly" type="text" size="30" value="${orderState[storageOrder.state] }" />
							<!-- <select name="storageOrder.state">
									<option value="0"<c:if test="${storageOrder.state == 0}">selected="selected"</c:if>>否</option>
									<option value="1"<c:if test="${storageOrder.isDelayed == 1}">selected="selected"</c:if>>是</option>
								</select> -->
							</p> --%>
							<p>
								<label>完成时间：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="30" value="${storageOrder.finishTime }" />
							</p>
							<p>
								<label>是否延期收货：</label>
								<select name="storageOrder.isDelayed">
									<option value="0"<c:if test="${storageOrder.isDelayed == 0}">selected="selected"</c:if>>否</option>
									<option value="1"<c:if test="${storageOrder.isDelayed == 1}">selected="selected"</c:if>>是</option>
								</select>
							</p>
							<p style="width: 1100px">
								<label>买家留言：</label>
								<input name="orders.inventory" readonly="readonly" type="text" size="155" value="${storageOrder.remark }" />
							</p>
						</fieldset>
						<div>
						<table class="table" targetType="dialog"  width="100%">
							<thead>
								<tr>
									<th width="30" align="center" >序号</th>
									<th width="100">三级订单编号</th>
									<th width="150">商品名称</th>
									<th width="150">商品规格</th>
									<th width="70">商品单价</th>
									<th width="70">购买数量</th>
									<th width="50">总价</th>
									<th width="50">积分</th>
									<th width="50">重量</th>
									<th width="70">虚拟商品</th>
									<th width="100">七天无理由退换</th>
									<th width="70">订单状态</th>
									<th width="100">退款金额</th>
									<th width="100">退款时间</th>
									<th width="100">完成时间</th>
									<!-- <th width="100">操作</th> -->
								</tr>
							</thead>
							<tbody>
							<c:forEach items="${storageOrder.goodsOrder}" var="goodsOrder" varStatus="status">
								<tr target="data_id" rel="${orders.id}">
									<td>${status.count}</td>
									<td>${goodsOrder.code}</td>
									<td>${goodsOrder.name}</td>
									<td>${goodsOrder.spec}</td>
									<td class="listMoneyField"><fmt:formatNumber value="${goodsOrder.price/100}" pattern="0.00"/></td>
									<td class="listMoneyField">${goodsOrder.num}</td>
									<td class="listMoneyField"><fmt:formatNumber value="${goodsOrder.totals/100}" pattern="0.00"/></td>
									<td class="listMoneyField">${goodsOrder.points}</td>
									<td class="listMoneyField">${goodsOrder.weight}</td>
									<td><c:if test="${goodsOrder.isVirtual == 0}">否</c:if><c:if test="${goodsOrder.isVirtual == 1}">是</c:if></td>
									<td><c:if test="${goodsOrder.isSevenDaysReturned == 0}">否</c:if><c:if test="${goodsOrder.isSevenDaysReturned == 1}">是</c:if></td>
									<td>${orderState[goodsOrder.state]}</td>
									<td class="listMoneyField"><fmt:formatNumber value="${goodsOrder.refundAmount/100}" pattern="0.00"/></td>
									<td><fmt:formatDate value="${goodsOrder.refundTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td><fmt:formatDate value="${goodsOrder.finishTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<%-- <td>
									    <a title="订单快照" target="dialog" width="1320" height="720" rel="orders_sku" href="${rootUrl}/order/orders-sku?ordersId=${goodsOrder.id}">订单快照</a>
									</td> --%>
								</tr>
							</c:forEach>
							</tbody>
						</table>
						</div>
					</div>
				</div>
			</div>
   		 </div>
    	<div class="formBar">
			<ul>
				<li id="export"><div class="<c:if test="${storageOrder.state != 30}">buttonDisabled</c:if><c:if test="${storageOrder.state == 30}">buttonActive</c:if>"><div class="buttonContent"><button <c:if test="${storageOrder.state != 30}">disabled="disabled"</c:if> onclick="exportOrder()" type="button">导出出库单</button></div></div></li>
				<li id="delivered"><div class="<c:if test="${storageOrder.state != 30}">buttonDisabled</c:if><c:if test="${storageOrder.state == 30}">buttonActive</c:if>"><div class="buttonContent"><button <c:if test="${storageOrder.state != 30}">disabled="disabled"</c:if> onclick="delivered()" type="button">确认发货</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
				</li>
			</ul>
		</div>
    </form>
</div>
<script>
	function exportOrder() {
		window.location.href='${rootUrl}/order/storage-order/${storageOrder.id}/exportOrder';
	}
	function delivered() {
		alertMsg.confirm("确定要发货成功该订单吗？", {
			okCall: function(){
				$("#mainFormId").attr("action","${rootUrl}/order/storage-order/${storageOrder.id}/delivered");
				$("#mainFormId").submit();
			}
		});
	}
</script>